﻿Imports System.Data.Common

'(DbConnection inherits from Component which causes this whole file to open in the VS Form designer, this attribute overrides that NOTE: must use fully qualified type name)
<System.ComponentModel.DesignerCategory("Code")> _
Friend Class FakeDbConnection
    Inherits DbConnection

    Public Sub New(nameOrConnectionString As String)
        ConnectionString = nameOrConnectionString
    End Sub

    Protected Overrides Function BeginDbTransaction(isolationLevel As System.Data.IsolationLevel) As System.Data.Common.DbTransaction
        Throw New NotImplementedException()
    End Function

    Public Overrides Sub ChangeDatabase(databaseName As String)
        Throw New NotImplementedException()
    End Sub

    Public Overrides Sub Close()
        Throw New NotImplementedException()
    End Sub

    Public Overrides Property ConnectionString As String

    Protected Overrides Function CreateDbCommand() As System.Data.Common.DbCommand
        Throw New NotImplementedException()
    End Function

    Public Overrides ReadOnly Property Database As String
        Get
            Throw New NotImplementedException()
        End Get
    End Property

    Public Overrides ReadOnly Property DataSource As String
        Get
            Throw New NotImplementedException()
        End Get
    End Property

    Public Overrides Sub Open()
        Throw New NotImplementedException()
    End Sub

    Public Overrides ReadOnly Property ServerVersion As String
        Get
            Throw New NotImplementedException()
        End Get
    End Property

    Public Overrides ReadOnly Property State As System.Data.ConnectionState
        Get
            Return ConnectionState.Closed
        End Get
    End Property

    Private _DbProviderFactory As DbProviderFactory = Nothing
    Protected Overrides ReadOnly Property DbProviderFactory As DbProviderFactory
        Get
            If _DbProviderFactory Is Nothing Then
                _DbProviderFactory = New FakeDbProviderFactory(_ConnectionString)
            End If

            Return _DbProviderFactory
        End Get
    End Property
End Class